package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaIntegralRecord;
import com.ruoyi.system.service.IJiajiaIntegralRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 积分记录信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@Controller
@RequestMapping("/jiajia/jiajiaIntegralRecord")
public class JiajiaIntegralRecordController extends BaseController
{
    private String prefix = "jiajia/jiajiaIntegralRecord";

    @Autowired
    private IJiajiaIntegralRecordService jiajiaIntegralRecordService;

    @RequiresPermissions("jiajia:jiajiaIntegralRecord:view")
    @GetMapping()
    public String jiajiaIntegralRecord()
    {
        return prefix + "/jiajiaIntegralRecord";
    }

    /**
     * 查询积分记录信息列表
     */
    @RequiresPermissions("jiajia:jiajiaIntegralRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaIntegralRecord jiajiaIntegralRecord)
    {
        startPage();
        List<JiajiaIntegralRecord> list = jiajiaIntegralRecordService.selectJiajiaIntegralRecordList(jiajiaIntegralRecord);
        return getDataTable(list);
    }

    /**
     * 导出积分记录信息列表
     */
    @RequiresPermissions("jiajia:jiajiaIntegralRecord:export")
    @Log(title = "积分记录信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaIntegralRecord jiajiaIntegralRecord)
    {
        List<JiajiaIntegralRecord> list = jiajiaIntegralRecordService.selectJiajiaIntegralRecordList(jiajiaIntegralRecord);
        ExcelUtil<JiajiaIntegralRecord> util = new ExcelUtil<JiajiaIntegralRecord>(JiajiaIntegralRecord.class);
        return util.exportExcel(list, "积分记录信息数据");
    }

    /**
     * 新增积分记录信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存积分记录信息
     */
    @RequiresPermissions("jiajia:jiajiaIntegralRecord:add")
    @Log(title = "积分记录信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaIntegralRecord jiajiaIntegralRecord)
    {
        return toAjax(jiajiaIntegralRecordService.insertJiajiaIntegralRecord(jiajiaIntegralRecord));
    }

    /**
     * 修改积分记录信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaIntegralRecord jiajiaIntegralRecord = jiajiaIntegralRecordService.selectJiajiaIntegralRecordById(id);
        mmap.put("jiajiaIntegralRecord", jiajiaIntegralRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存积分记录信息
     */
    @RequiresPermissions("jiajia:jiajiaIntegralRecord:edit")
    @Log(title = "积分记录信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaIntegralRecord jiajiaIntegralRecord)
    {
        return toAjax(jiajiaIntegralRecordService.updateJiajiaIntegralRecord(jiajiaIntegralRecord));
    }

    /**
     * 删除积分记录信息
     */
    @RequiresPermissions("jiajia:jiajiaIntegralRecord:remove")
    @Log(title = "积分记录信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaIntegralRecordService.deleteJiajiaIntegralRecordByIds(ids));
    }
}
